<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="${staticServer}/inc/style/main.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/page.css" />
<link rel="stylesheet" href="${staticServer}/css/work_today.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css" />
<script src="${staticServer}/inc/js/jquery.js"></script>
<script src="${staticServer}/inc/js/pageset.js"></script>
<script src="${staticServer}/inc/js/datepicker.js"></script>
<script src="${staticServer}/inc/js/infopad.js?2.2"></script>

<script src="${staticServer}/inc/js/tips.js?1.4"></script>
<script>
var addDuty = function(id){
	if(id==null || id==""){
		id = $("#id").val();
	}
	
	var duty = $("#duty").html();
	
	if(duty==""){
		infopad.err("请填写工作职责!");
		return;
	}
	
	$.post("${contextPath}/index/add_duty.json", {
			"id":id,
			"duty":duty
		}, function(ms) {
		    var msg = ms.msg;
		    if(msg!=null && msg=="1"){
				infopad.msg("操作成功！");
				location.reload() 
		    }else{
		    	infopad.err("操作失败，请联系管理员！");
		    }
			
	});
};

var addDuty2 = function(id){
	var duty = $("#duty"+id).html();
	
	if(duty==""){
		infopad.err("请填写工作职责!");
		return;
	}
	
	$.post("${contextPath}/index/add_duty.json", {
			"id":id,
			"duty":duty
		}, function(ms) {
		    var msg = ms.msg;
		    if(msg!=null && msg=="1"){
				infopad.msg("操作成功！");
				location.reload() 
		    }else{
		    	infopad.err("操作失败，请联系管理员！");
		    }
			
	});
};
</script>
</head>

<body>
<input type="hidden" id="id" value="<#if dt??>${dt.id}</#if>">
	<div id="home_link">
		<ul>
			<li>竞思教育网络办公系统 v2.0 beta</li>
			<li>&gt;</li>
			<li>工作管理</li>
			<li>&gt;</li>
			<li class="current"></li>
		</ul>
	</div>
	<div id="container">
		<div id="title">职责列表</div>
		
		<table>
			<tr class="fields">
				<th width="10%">姓名</th>
				<th width="20%">中心地址</th>
				<th width="20%">职位</th>
				<th>工作职责</th>
				<th width="10%">操作</th>
			</tr>
			
		<#if webutil.getCookieUser().username=="system" || webutil.getCookieUser().username=="lisha" || webutil.getCookieUser().username=="liulan" ||webutil.getCookieUser().username=="yuanjing">
			
			<#if list??>
				<#list list as list><#if list.username="lisha" || list.username="liulan" || list.username="yuanjing">
				<tr>
					<td rel="select_time" align="center"><span></span><p class="caption">${webutil.getCookieUser().nickname}</p></td>
					<td align="center">${webutil.getCookieUser().regions}</td>
					<td align="center">${webutil.getCookieUser().departments}（${webutil.getCookieUser().job}）</td>
					<td><div contenteditable="true" id="duty" >${list.duty}</div></td>
					<td align="center"><input type="button" value="  保存  " onclick="addDuty(${list.id})"></td>
				</tr>
				<#else>
				<tr class="even_row">
					<td align="center">${list.nickname}</td>
					<td align="center">${list.center}</td>
					<td align="center">${list.departments}（${list.job}）</td>
					<!--<td> <div contenteditable="true" id="duty${list.id}"   ><#if list.duty?length gt 18>${list.duty?substring(0,18)}...<#else>${list.duty}</#if></div></td>-->
					<td title="${list.duty}" contenteditable="true" id="duty${list.id}">
						<#if (list.duty?length > 20)>${list.duty?substring(0,15)}...<#else>
						${list.duty}</#if></td>
					<td align="center"></td>
				<!--	<td align="center"></td> -->
				</tr>
				</#if>
				</#list>
			</#if>
			
		<#else>
			<tr>
				<td rel="select_time" align="center"><span></span><p class="caption">${webutil.getCookieUser().nickname}</p></td>
				<td align="center">${webutil.getCookieUser().regions}</td>
				<td align="center">${webutil.getCookieUser().departments}（${webutil.getCookieUser().job}）</td>
				<td><div contenteditable="true" id="duty" ><#if dt?? && dt.duty??>${dt.duty}</#if></div></td>
				<td align="center"><input type="button" value="  保存  " onclick="addDuty()"></td>
			</tr>
		</#if>
			
		</table>
	</div>
	<div id="pager" style="width: 820px;">
	<ul id="pagination">
		<#if page??>
		<#if page.pagetotal?? && page.pagetotal!="0">
	<#assign pagetotal = page.pagetotal>
	<#else>
	<#assign pagetotal = 1>
	</#if>
			<#if page.currpage??>
	<#assign currpage = page.currpage>
	<#else>
	<#assign currpage = 1>
	</#if>
				<#if currpage==1 >
					<li class="previous-off">上一页</li>
					<#else>
					<li class="previous"><a href="${contextPath}/index/work_duty_list.htm?currPage=${currpage-1}">上一页</a></li>
					</#if>
					
		<#if pagetotal<=11>
			<#list 1..pagetotal as index_up>  
	           <#if currpage==index_up > 
	           		<li class="current">${index_up}</li>
	           <#else>
	           		<li><a href="${contextPath}/index/work_duty_list.htm?currPage=${index_up}">${index_up}</a></li>  
	           </#if>  
			</#list>  
		<#else>
			<#if currpage<=8 >
				<#list 1..9 as index_up>  
	           	<#if currpage==index_up >  
	            	<li class="current">${index_up}</li>
	           	<#else>  
	               <li><a href="${contextPath}/index/work_duty_list.htm?currPage=${index_up}">${index_up}</a></li> 
	           	</#if>
	           	</#list>  
	           	<li>...</li>
	           	<li><a href="${contextPath}/index/work_duty_list.htm?currPage=${pagetotal}">${pagetotal}</a></li>  
				
			<#elseif (currpage>= 9 && currpage<pagetotal-7)  >	
				<li><a href="${contextPath}/index/work_duty_list.htm?currPage=1">1</a></li>  
				<li>...</li>
				<#list currpage-3..currpage+3 as index_up>  
	           	<#if currpage==index_up >  
	             <li class="current">${index_up}</li>
	           	<#else>  
	               <li><a href="${contextPath}/index/work_duty_list.htm?currPage=${index_up}">${index_up}</a></li>  
	           	</#if>
	           	</#list>
				<li>...</li>
	           	<li><a href="${contextPath}/index/work_duty_list.htm?currPage=${pagetotal}">${pagetotal}</a></li>   
			<#else>
				<li><a href="${contextPath}/index/work_duty_list.htm?currPage=1">1</a></li> 
				<li>...</li>
				<#list pagetotal-8..pagetotal as index_up>  
	           	<#if currpage==index_up >  
	             <li class="current">${index_up}</li>
	           	<#else>  
	               <li><a href="${contextPath}/index/work_duty_list.htm?currPage=${index_up}">${index_up}</a></li> 
	           	</#if>
				</#list>  
			</#if>
			
		</#if> 
		<#if currpage==pagetotal >
		 	<li class="previous-off">下一页</li>
		<#else>
			<li class="previous"><a href="${contextPath}/index/work_duty_list.htm?currPage=${currpage+1}">下一页</a></li>
		</#if>
		<li class="pageinfo">共${page.total}条记录</li>
	</#if>
	</ul>
	</div>
	<div class="emptyline clear"></div>
</body>
<script>	
	<#if list??>
		<#list list as list>
			$(function(){
				$("#duty${list.id}").focus(function(){
					$("#duty${list.id}").html("${list.duty}");
				})
				$("#duty${list.id}").blur(function(){
					$("#duty${list.id}").html("<#if (list.duty?length > 20)>${list.duty?substring(0,15)}...<#else>${list.duty}</#if>");
				})
			})
		</#list>
	</#if>	
</script>
</html>